'use client'
import './globals.css'
import { useState } from 'react'
interface WrapperProps {
    chilren:React.ReactNode
}
const ErrorSimulator=({
    message='An error occurren'
}:{
    message?:string
})=>{
    const [error,setError] =useState(false)
    if(error) throw new Error(message)
    return (
        <div>
            <button onClick={()=>setError(true)}>Simulate Error</button>
        </div>
    )
}
export const ErrorWrapper=({children}:WrapperProps)=>{
    return (
        <div>
            <div>
                <ErrorSimulator message='simulated error in root layout'/>
            </div>
            {children}
        </div>
    )
}
